package com.oracle.service.impl;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.oracle.compents.PageResult;
import com.oracle.mapper.PhOrderinfoMapper;
import com.oracle.pojo.PhOrderinfo;
import com.oracle.pojo.PhOrderinfoExample;
import com.oracle.pojo.PhOrderinfoExample.Criteria;
import com.oracle.service.OrderinfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 服务实现层
 * @author Administrator
 *
 */
@Service
public class OrderinfoServiceImpl implements OrderinfoService {

	@Autowired
	private PhOrderinfoMapper orderinfoMapper;

	/**
	 * 查询全部
	 */
	@Override
	public List<PhOrderinfo> findAll() {
		return orderinfoMapper.selecPhyExample(null);
	}

	/**
	 * 按分页查询
	 */
	@Override
	public PageResult findPage(int pageNum, int pageSize) {
		PageHelper.startPage(pageNum, pageSize);
		Page<PhOrderinfo> page=   (Page<PhOrderinfo>) orderinfoMapper.selecPhyExample(null);
		return new PageResult(page.getTotal(), page.getResult());
	}

	/**
	 * 增加
	 */
	@Override
	public void add(PhOrderinfo orderinfo) {
		orderinfoMapper.insert(orderinfo);
	}


	/**
	 * 修改
	 */
	@Override
	public void update(PhOrderinfo orderinfo){
		orderinfoMapper.updateByPrimaryKey(orderinfo);
	}

	/**
	 * 根据ID获取实体
	 * @param id
	 * @return
	 */
	@Override
	public PhOrderinfo findOne(Integer orderid){
		return orderinfoMapper.selecPhyPrimaryKey(orderid);
	}

	/**
	 * 批量删除
	 */
	@Override
	public void delete(Integer[] orderids) {
		for(Integer orderid:orderids){
			orderinfoMapper.deleteByPrimaryKey(orderid);
		}
	}


		@Override
	public PageResult findPage(PhOrderinfo orderinfo, int pageNum, int pageSize) {
		PageHelper.startPage(pageNum, pageSize);

		PhOrderinfoExample example=new PhOrderinfoExample();
		Criteria criteria = example.createCriteria();

		if(orderinfo!=null){

		}

		Page<PhOrderinfo> page= (Page<PhOrderinfo>)orderinfoMapper.selecPhyExample(example);
		return new PageResult(page.getTotal(), page.getResult());
	}

}
